layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 库区表管理
     */
    var MovingPalletsmerge = {
        tableId: "movingPalletsmergeTable"
    };

    /**
     * 初始化表格的列
     */
    MovingPalletsmerge.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'id', hide: true, title: '主键'},
            {field: '', title: '序号', type:'numbers', width: 120},
            {field: 'typr', sort: true, title: '类型', style:'font-weight: 600;'},
            {field: 'goodsName', sort: true, title: '商品名称', style:'font-weight: 600;'},
            {field: 'goodsNumber', sort: true, title: '商品编号', style:'font-weight: 600;'},
            {field: 'goodsNo', sort: true, title: '货号', style:'font-weight: 600;'},
            {field: 'sourcewarehouseName', sort: true, title: '源仓库名称', style:'background-color: #ecf5ff;font-weight: 600;'},
            {field: 'sourceareaNumber', sort: true, title: '源库区编号', style:'background-color: #ecf5ff;font-weight: 600;'},
            {field: 'sourcepositionNumber', sort: true, title: '源库位编号', style:'background-color: #ecf5ff;font-weight: 600;'},
            {field: 'sourcetrayNumber', sort: true, title: '源托盘编号', style:'background-color: #ecf5ff;font-weight: 600;'},
            {field: 'sourcenum', sort: true, title: '源数量-', style:'background-color: #ecf5ff;font-weight: 600;'},

            {field: 'aimwarehouseName', sort: true, title: '目的仓库名称', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'aimareaNumber', sort: true, title: '目的库区编号', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'aimpositionNumber', sort: true, title: '目的库位编号', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'aimtrayNumber', sort: true, title: '目的托盘编号', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'aimnum', sort: true, title: '目的数量+', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'nodes', sort: true, title: '操作人', style:'font-weight: 600;'},
            {field: 'createTime', sort: true, title: '操作时间', style:'font-weight: 600;'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    MovingPalletsmerge.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        queryData['typr'] = $("#typr").val();
        queryData['nodes'] = $("#nodes").val();
        table.reload(MovingPalletsmerge.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    /**
     * 导出excel按钮
     */
    MovingPalletsmerge.exportExcel = function () {
        var checkRows = table.checkStatus(MovingPalletsmerge.tableId);
        if (checkRows.data.length === 0) {
            Feng.error("请选择要导出的数据");
        } else {
            table.exportFile(tableResult.config.id, checkRows.data, 'xls');
        }
    };


    // 渲染表格
    var tableResult = table.render({
        elem: '#' + MovingPalletsmerge.tableId,
        url: Feng.ctxPath + '/movingPalletsmerge/cxlist',
        page: true,
        limit: 60,
        height: "full-60",
		limits:[60,120,240,360,480,1500,5000],
        toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
        cellMinWidth: 100,
        cols: MovingPalletsmerge.initColumn()
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        MovingPalletsmerge.search();
    });

    // 导出excel
    $('#btnExp').click(function () {
        MovingPalletsmerge.exportExcel();
    });

});
